<?php

/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the controller to call when that URI is requested.
|
 */

// Route::get('/', function () {
// 	return view('welcome');
// });
//后台路由规则
Route::group(['middleware' => 'login'], function () {
	Route::get('admin', 'adminController@index');
	// 注销登录
	Route::get('admin/logout', 'adminController@logout');
	//用户模块规则
	Route::resource('admin/user', 'UserController');
	//栏目模块规则
	Route::resource('admin/column', 'ColumnController');
	//文章模块规则
	Route::get('admin/article', 'ArticleController@index');
	Route::get('admin/art/show', 'ArticleController@showDelArt');
	Route::get('admin/art/del-{id}', 'ArticleController@destroy');
	Route::get('admin/art/edit-{id}.html', 'ArticleController@edit');
	Route::get('admin/art/com-{id}', 'ArticleController@update');
	//话题模块规则
	Route::get('admin/topic', 'TopicController@index');
	Route::get('admin/topic/show', 'TopicController@showDelTopic');
	Route::get('admin/topic/create', 'TopicController@create');
	Route::post('admin/topic', 'TopicController@store');
	Route::get('admin/topic/del-{id}', 'TopicController@destroy');
	Route::get('admin/topic/edit-{id}.html', 'TopicController@edit');
	Route::get('admin/topic/com-{id}', 'TopicController@update');
	//问题模块规则
	Route::get('admin/question', 'QuestionController@index');
	Route::get('admin/question/show', 'QuestionController@showDelQuestion');
	Route::get('admin/question/del-{id}', 'QuestionController@destroy');
	Route::get('admin/question/edit-{id}.html', 'QuestionController@edit');
	Route::get('admin/question/com-{id}', 'QuestionController@update');
});
//后台登录规则
Route::get('login/admin', 'adminController@login');
Route::post('login/admin', 'adminController@doLogin');

//API接口路由规则
Route::group([], function () {
	Route::post('/api/login', 'APIController@login');
	Route::resource('/api', 'APIController');
	Route::post('/api/topic-{id}', 'APIController@getTopics')->where('id', '\d+'); //ajax获取指定栏目下的话题
	Route::post('/api/discuss', 'APIController@discuss'); //ajax发表评论
	Route::post('/api/question', 'APIController@question'); //ajax发表问题
	Route::post('/api/column', 'APIController@getColumn'); //ajax获取所有栏目信息
	Route::post('/api/admire', 'APIController@admire'); // 点赞
	Route::post('/api/checkName', 'APIController@checkName'); // 检测用户昵称是否存在
	Route::post('/api/imgUpload', 'APIController@imgUpload'); // 图片上传
	Route::post('/api/bgImgUpload', 'APIController@bgImgUpload'); // 图片上传
	Route::post('/api/setting', 'APIController@setting'); // 用户信息修改
	Route::post('/api/setFace', 'APIController@setFace'); // 用户信息修改
	Route::post('/api/sendEmail', 'APIController@sendEmail'); // 发送邮件
	Route::post('/api/sendPhone', 'APIController@sendPhone'); // 发送邮件
	Route::post('/api/change', 'APIController@change'); // 发送邮件
	Route::post('/api/chat', 'APIController@chat'); // 发送邮件
});

//前台路由规则
Route::group(['middleware' => 'homeLogin'], function () {
	Route::get('/logout', 'PeopleController@logout'); //注销登录
	Route::get('/', 'HomeController@index'); //主页规则
	Route::get('/write', 'HomeController@write'); //文章编辑页
	Route::post('/write', 'HomeController@doWrite'); //处理文章内容
	Route::get('/article/{id}', 'HomeController@article')->where('id', '\d+'); //文章详情页
	Route::get('/topic', 'HomeController@topic'); //话题列表
	Route::get('/topic/{id}', 'HomeController@getArticle')->where('id', '\d+'); //某话题下的文章
	Route::get('/column/{id}', 'HomeController@column')->where('id', '\d+'); //栏目下文章列表
	Route::get('/question', 'HomeController@question'); //问题列表
	Route::get('/question/{id}.html', 'HomeController@questionShow')->where('id', '\d+'); //问题详情列表
	Route::get('/search', 'HomeController@search'); //搜索页
	Route::get('/explode', 'HomeController@explode'); //随机显示文章列表
	Route::get('/message', 'HomeController@message'); //私信列表
	Route::get('/people', 'PeopleController@index'); //个人主页
	Route::get('/setting', 'PeopleController@setting'); //设置
	Route::get('/repasswd', 'PeopleController@repasswd'); //修改密码
	Route::get('/show/{id}', 'PeopleController@show')->where('id', '\d+'); //个人页面展示
	Route::get('/submit', 'PeopleController@success'); //个人页面展示
});

//前台登录注册
Route::get('/login', 'PeopleController@login');
Route::post('/login', 'PeopleController@doLogin');
Route::post('/register', 'PeopleController@register'); //接受注册
Route::post('/register/api', 'PeopleController@checkUname'); //检测用户名